package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

//这里是跳转页面,所以不用RestController
@Controller
public class PageController {
    @Autowired
    private PageService pageService;

    //跳转到商品详情页
    @GetMapping("item/{id}.html")
    public String loadItemPage(Model model, @PathVariable("id") Long id) {
        Map<String, Object> itemMap = pageService.loadItemPage(id);
        model.addAllAttributes(itemMap);
        return "item";
    }

}
